home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 8.6 KB | 283 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPat.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWPAT_H
- #include "FWPat.h"
- #endif
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef FWSTRMRW_H
- #include "FWStrmRW.h"
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Pattern
- #endif
-
- //========================================================================================
- // Template instantiation
- //========================================================================================
-
- #include "FWGrRef.tpp"
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TGrRefPtr, FW_HPattern)
-
- #ifdef FW_USE_TEMPLATE_PRAGMAS
-
- #pragma template_access public
- #pragma template FW_TGrRefPtr<FW_HPattern>
-
- #else
-
- template class FW_TGrRefPtr<FW_HPattern>;
-
- #endif
-
- //========================================================================================
- // class FW_CPattern
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CPattern)
-
- //----------------------------------------------------------------------------------------
- // FW_PrivAcquireGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivAcquireGrRep(FW_HPattern rep)
- {
- if (rep != 0)
- FW_PrivPattern_Acquire(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivReleaseGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivReleaseGrRep(FW_HPattern rep)
- {
- if (rep != 0)
- FW_PrivPattern_Release(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FW_CPattern
- //----------------------------------------------------------------------------------------
-
- FW_CPattern::FW_CPattern()
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FW_CPattern
- //----------------------------------------------------------------------------------------
-
- FW_CPattern::FW_CPattern(FW_HPattern rep)
- {
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FW_CPattern
- //----------------------------------------------------------------------------------------
-
- FW_CPattern::FW_CPattern(const FW_BitPattern& bits)
- {
- FW_PlatformError error;
- FW_HPattern rep = FW_PrivPattern_CreateBW(bits, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FW_CPattern
- //----------------------------------------------------------------------------------------
-
- FW_CPattern::FW_CPattern(const FW_PixelPattern& pixels, short nbColors, const FW_CColor* colorTable)
- {
- FW_PlatformError error;
- FW_HPattern rep = FW_PrivPattern_CreateColor(pixels, nbColors, colorTable, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FW_CPattern
- //----------------------------------------------------------------------------------------
-
- FW_CPattern::FW_CPattern(FW_PlatformColorPattern pattern)
- {
- FW_PlatformError error;
- FW_HPattern rep = FW_PrivPattern_CreateFromPlatformColorPattern(pattern, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FW_CPattern
- //----------------------------------------------------------------------------------------
-
- FW_CPattern::FW_CPattern(const FW_CPattern& other) :
- FW_TGrRefPtr<FW_HPattern>(other)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FW_CPattern
- //----------------------------------------------------------------------------------------
-
- FW_CPattern::~FW_CPattern()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CPattern& FW_CPattern::operator=(const FW_CPattern& other)
- {
- FW_TGrRefPtr<FW_HPattern>::operator=(other);
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CPattern& FW_CPattern::operator=(const FW_BitPattern& bits)
- {
- FW_PlatformError error;
- FW_HPattern rep = FW_PrivPattern_CreateBW(bits, &error);
- FW_FailOnError(error);
- SetRep(rep);
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CPattern FW_CPattern::Copy() const
- {
- FW_PlatformError error;
- FW_HPattern rep = FW_PrivPattern_Copy(fRep, &error);
- FW_FailOnError(error);
-
- FW_CPattern pattern;
- pattern.SetRep(rep);
- return pattern;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::Invert
- //----------------------------------------------------------------------------------------
-
- void FW_CPattern::Invert()
- {
- FW_FailOnError(FW_PrivPattern_Invert(fRep));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FlipHorizontally
- //----------------------------------------------------------------------------------------
-
- void FW_CPattern::FlipHorizontally()
- {
- FW_FailOnError(FW_PrivPattern_FlipHorizontally(fRep));
- }
- //----------------------------------------------------------------------------------------
- // FW_CPattern::FlipVertically
- //----------------------------------------------------------------------------------------
-
- void FW_CPattern::FlipVertically()
- {
- FW_FailOnError(FW_PrivPattern_FlipVertically(fRep));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::ShiftUp
- //----------------------------------------------------------------------------------------
-
- void FW_CPattern::ShiftUp()
- {
- FW_FailOnError(FW_PrivPattern_ShiftUp(fRep));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::ShiftDown
- //----------------------------------------------------------------------------------------
-
- void FW_CPattern::ShiftDown()
- {
- FW_FailOnError(FW_PrivPattern_ShiftDown(fRep));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::ShiftLeft
- //----------------------------------------------------------------------------------------
-
- void FW_CPattern::ShiftLeft()
- {
- FW_FailOnError(FW_PrivPattern_ShiftLeft(fRep));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPattern::ShiftRight
- //----------------------------------------------------------------------------------------
-
- void FW_CPattern::ShiftRight()
- {
- FW_FailOnError(FW_PrivPattern_ShiftRight(fRep));
- }
-
- //========================================================================================
- // Stream I/O
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // operator>>
- //----------------------------------------------------------------------------------------
-
- FW_CReadableStream& operator>>(FW_CReadableStream& stream, FW_CPattern& pattern)
- {
- FW_PlatformError error;
- FW_HPattern rep = FW_PrivPattern_Read(stream, &error);
- FW_FailOnError(error);
- pattern.SetRep(rep);
- return stream;
- }
-
- //----------------------------------------------------------------------------------------
- // operator<<
- //----------------------------------------------------------------------------------------
-
- FW_CWritableStream& operator<<(FW_CWritableStream& stream, const FW_CPattern& pattern)
- {
- FW_PlatformError error;
- FW_PrivPattern_Write(pattern.fRep, stream, &error);
- FW_FailOnError(error);
- return stream;
- }
-
-